﻿using System.Collections.Generic;
using System.Threading;
using AForge.Imaging;

namespace MD.ImageProcessing.Cell
{
    public static class Generator
    {
        public static int id = 0;

        public static int GetId()
        {
            return Interlocked.Increment(ref id);
        }
    }

    public class Cell
    {
        public Cell(Blob blob)
        {
            //Id = Guid.NewGuid();
            Id = Generator.GetId();
            var state = new CellState(Id);
            state.State = blob;

            States.Add(state);
        }

        public Cell(CellState state)
        {
            //Id = Guid.NewGuid();
            Id = Generator.GetId();
            state.CellId = Id;
            States.Add(state);
        }

        public void AddState(CellState cellState)
        {
            cellState.CellId = Id;
            States.Add(cellState);
        }

        /// <summary>
        /// Cell ID
        /// </summary>
        //public Guid Id { get; set; }
        public int Id { get; set; }

        public CellState LastState { get { return States[States.Count == 0 ? 0 : States.Count - 1]; } }

        public List<CellState> States = new List<CellState>();
    }
}